using DG.Tweening;
using UnityEngine;

public class WindowStageHard : MonoBehaviour
{
	public GameObject table_stage;

	public GameObject tab_center;

	public GameObject GiftCode;

	public GameObject[] stage;

	public GameObject[] LockStage;

	public GameObject[] ColorStage;

	public GameObject[] EffselectMap;

	public GameObject systemGift;

	private void OnEnable()
	{
		Sequence mySequence = DOTween.Sequence();
		mySequence.Insert(0f, table_stage.transform.DOMoveY(-6f, 0.25f).From().SetEase(Ease.OutBack));
		mySequence.Insert(1f, tab_center.GetComponent<tk2dSprite>().DOScaleX(1f, 0.25f).SetEase(Ease.Linear));
		mySequence.OnComplete(delegate
		{
			openCallback(mySequence);
		});
	}

	private void Start()
	{
		for (int i = 0; i < GameManager.key_stageHard; i++)
		{
			LockStage[i].gameObject.GetComponent<Collider>().enabled = true;
			ColorStage[i].SetActive(value: false);
		}
		EffselectMap[GameManager.key_stageHard - 1].SetActive(value: true);
		GiftCode.transform.DOScale(1f, 3f).SetEase(Ease.OutBack);
	}

	private void openCallback(Sequence sequence)
	{
		AudioController.Instance.SoundButtonAllGame();
		switch (GameManager.map)
		{
		case 1:
			stage[0].SetActive(value: true);
			break;
		case 2:
			stage[1].SetActive(value: true);
			break;
		case 3:
			stage[2].SetActive(value: true);
			break;
		case 4:
			stage[3].SetActive(value: true);
			break;
		case 5:
			stage[4].SetActive(value: true);
			break;
		case 6:
			stage[5].SetActive(value: true);
			break;
		}
		sequence.Kill();
		if (GameManager.Tutorial == 0)
		{
			GameObject.Find("btn-back").GetComponent<Collider>().enabled = false;
		}
		if (GameManager.Tutorial == 2)
		{
			GameObject.Find("btn-back").GetComponent<Collider>().enabled = false;
			GameObject.Find("btn-stage-1").GetComponent<Collider>().enabled = false;
		}
	}

	public void onClickReturn()
	{
		AudioController.Instance.SoundButtonAllGame();
		for (int i = 0; i < stage.Length; i++)
		{
			stage[i].SetActive(value: false);
		}
		Sequence mySequence = DOTween.Sequence();
		mySequence.Insert(0f, tab_center.GetComponent<tk2dSprite>().DOScaleX(0.1f, 0.25f).SetEase(Ease.Linear));
		mySequence.Insert(1f, table_stage.transform.DOMoveY(6f, 0.25f).SetEase(Ease.InBack));
		mySequence.OnComplete(delegate
		{
			closeCallback(mySequence);
		});
	}

	private void closeCallback(Sequence sequence)
	{
		AudioController.Instance.SoundButtonAllGame();
		base.gameObject.SetActive(value: false);
		table_stage.transform.localPosition = new Vector3(0f, 0f, 0f);
		sequence.Kill();
	}

	private void OnclickGiftCode()
	{
		systemGift.SetActive(value: true);
	}

	private void OnclickWatchVideo()
	{
		AdsVideoController.ShowAds();
		systemGift.SetActive(value: false);
		GiftCode.SetActive(value: false);
	}

	private void OnclickNothank()
	{
		systemGift.SetActive(value: false);
		GiftCode.SetActive(value: false);
	}
}
